import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm';
import { User } from './user.entity';

@Entity('user_login')
export class UserLogin {
  @PrimaryGeneratedColumn({ comment: '自增主键' })
  id: number;
  @Column()
  user_id: string;
  @Column({
    comment: '登录时间',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  login_time: Date;

  @Column({ comment: '登录设备', nullable: true, length: 100 })
  device: string;

  @Column({ comment: '登录IP', nullable: true, length: 50 })
  ip: string;

  @Column({ comment: 'token', nullable: true, length: 500 })
  token: string;
  //   表关联
  @ManyToOne(() => User, (user) => user.logins)
  user: User;

  // 平台类型
  @Column({
    type: 'varchar',
    name: 'platform_type',
    default: '1',
    comment: '平台类型',
    length: 50,
  })
  platform_type: string;
}
